package com.liu.mapper;

import com.liu.common.ParentTemplate;
import com.liu.common.Template;




/**
 * @author Mr.Liu
 * @version 1.0
 * @date 2024/8/31 10:55
 */
public class MapperTemplate extends ParentTemplate implements Template {

    private static final  String SUFFIX = "Mapper";
    private static  final  String EXTENDS_PARENT = "CommonModel";

    @Override
    public String toTemplate() {

        StringBuffer sb = new StringBuffer();
        sb.append("package "+this.getPackageName()+".mapper;\n");
        sb.append("import java.util.List;\n");
        sb.append("import "+this.getPackageName()+".model."+this.getClassName()+"Model;\n\n");

        sb.append("@Getter\n");
        sb.append("@Setter\n");
        sb.append("public interface "+getClassName()+SUFFIX +" {\n\n");
        sb.append("    int insert("+this.getClassName()+"Model model);\n");
        sb.append("    int delete("+this.getClassName()+"Model model);\n");
        sb.append("    int update("+this.getClassName()+"Model model);\n");
        sb.append("    Date getLastUpdateDate(Integer "+this.getPrimaryKey()+");\n");
        sb.append("    int update(Integer "+this.getPrimaryKey()+");\n");
        sb.append("    List<"+this.getClassName()+"Model> search("+this.getClassName()+"Model model);\n");
        sb.append("    "+this.getClassName()+"Model searchById(Integer "+this.getPrimaryKey()+");\n");
        sb.append("    int searchCount("+this.getClassName()+"Model model);\n");
        sb.append("    int deleteByIds(List<Integer> ids);\n");
        sb.append("    int deleteNoInIds(List<Integer> ids);\n\n");
        sb.append("}");

        return sb.toString();
    }
}
